package com.ls.common;



import com.ls.system.entity.SysUser;
import com.ls.system.service.SysUserService;
import org.camunda.bpm.engine.identity.*;
import org.camunda.bpm.engine.impl.identity.ReadOnlyIdentityProvider;
import org.camunda.bpm.engine.impl.interceptor.CommandContext;

import org.camunda.bpm.engine.impl.persistence.entity.UserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * @Author lisheng
 * @Date 2025/04/16 14:04
 **/
@Component
public class CustomIdentityProvider implements ReadOnlyIdentityProvider {

    @Autowired
    private SysUserService sysUserService;

    @Override
    public User findUserById(String userId) {
        SysUser sysUser = sysUserService.getById(Long.parseLong(userId));
        if (sysUser == null) {
            return null;
        }

        UserEntity userEntity = new UserEntity();
        userEntity.setId(sysUser.getId().toString());
        userEntity.setFirstName(sysUser.getName());
        // 可选设置其他字段
        // userEntity.setEmail(sysUser.getEmail());
        return userEntity;
    }

    @Override
    public UserQuery createUserQuery() {
//        return new CustomUserQuery(sysUserService); // 需实现自定义UserQuery
        return null;
    }


    @Override
    public UserQuery createUserQuery(CommandContext commandContext) {
        return null;
    }

    @Override
    public NativeUserQuery createNativeUserQuery() {
        return null;
    }

    @Override
    public boolean checkPassword(String userId, String password) {
        return false;
    }

    @Override
    public Group findGroupById(String groupId) {
        return null;
    }

    @Override
    public GroupQuery createGroupQuery() {
        return null;
    }

    @Override
    public GroupQuery createGroupQuery(CommandContext commandContext) {
        return null;
    }

    @Override
    public Tenant findTenantById(String tenantId) {
        return null;
    }

    @Override
    public TenantQuery createTenantQuery() {
        return null;
    }

    @Override
    public TenantQuery createTenantQuery(CommandContext commandContext) {
        return null;
    }

    @Override
    public void flush() {

    }

    @Override
    public void close() {

    }
}
